import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:flutter/material.dart';

import '../modules/home/home_binding.dart';
import '../modules/home/home_page.dart';

class AuthMiddleware extends GetMiddleware {
  @override
  RouteSettings? redirect(String? route) {
    var lockBox = Hive.box(name: "lock");
    return lockBox.get("isLock") ? const RouteSettings(name: '/lock') : null;
  }
}

class HomeRoutes {
  HomeRoutes._();

  static const home = '/home';

  static final routes = [
    GetPage(
      name: home,
      page: () => const HomePage(),
      binding: HomeBinding(),
      middlewares: [AuthMiddleware()],
    ),
  ];
}
